/*
 * 
 * Version 1.00
 * 
 * Created on 2007-6-4
 * Encoding GB2312
 */
package net.comm.friend.service.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;
import java.util.Vector;

import net.comm.check.service.impl.JifenServiceImpl;
import net.comm.common.GlbFinal;
import net.comm.common.ReturnMessage;
import net.comm.common.common;


import net.comm.friend.bean.BaseLinju;
import net.comm.friend.db.DbLinjuService;
import net.comm.friend.db.LinjuServiceSqlMysql;
import net.comm.friend.web.form.BlacklistForm;
import net.comm.friend.web.form.LinjuForm;
import net.comm.message.service.impl.MessageServiceImpl;
import net.comm.message.web.form.MessageForm;
import net.comm.message.web.form.MsgcontForm;
import net.comm.oper.service.impl.OperLogServiceImpl;
import net.comm.oper.web.form.OperLogForm;
import net.comm.page.PageCtr;

import net.comm.tags.JstlFun;
import net.comm.user.service.impl.UserSysinfoServiceImpl;
import net.comm.user.web.form.UserSysinfoForm;
import net.comm.util.DatetimeUtil;
import net.comm.util.DbcpPool;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.sakaiproject.db.impl.BasicSqlService;

/**
 *
 * @author hcgong(hcgong@sina.com)
 * @version 1.0
 * @date 2007-6-4
 */
public class LinjuServiceImpl {

	static Logger logger = Logger.getLogger(LinjuServiceImpl.class.getName());

	/**
	 * 
	 * @see net.IUserbasicService.module.other.IUserService
	 * 		#list(net.swift.module.other.ExaQueryBean, net.swift.common.ReturnMessage)
	 */
	public List list(LinjuForm theForm,  ReturnMessage msg) 
	{
		List list = null;

		Connection cn = null;

		try
		{
			cn = DbcpPool.getConnection();
			
			LinjuServiceSqlMysql servSql = new LinjuServiceSqlMysql();
			BasicSqlService  bSqlServ = new BasicSqlService();

			/*
			 * 获得查询SQL语句
			 */
			String sql = servSql.getCountSql2();

			//取得FORM中传入的查询参数
			Object[] fields1 = new Object[1];
			fields1[0] = theForm.getQryUserID();

			/**
			 * 根据SQL执行结果计算分页相关信息
			 */
			PageCtr page = theForm.getPage();
			page.setTotalNum(bSqlServ.dbCount(cn, sql, fields1));
			page.caculate();

			//取得FORM中传入的查询参数
			Object[] fields = new Object[3];
			
			fields[0] = theForm.getQryUserID();
			fields[1] = page.getPos()-1;
			fields[2] = page.getPageSize();
			
			sql = servSql.getRecbyPageSql();

			list = bSqlServ.dbRead(cn, sql, fields, new DbLinjuService());
			
		    DbcpPool.returnConnection(cn);
		    
		} catch(Exception ex) 
		{
			/**
			 * 记录相关日志
			 */
			logger.error(ex.getMessage());
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
			
		} finally {
			DbcpPool.returnConnection(cn);
		}		
		
		return list;
	}

	/**
	 * 返回根据会员ID查询的会员好友
	 */
	public List list(int  userID, String status) 
	{
		List list = null;
		Connection cn = null;

		try
		{
			cn = DbcpPool.getConnection();
			
			LinjuServiceSqlMysql servSql = new LinjuServiceSqlMysql();
			BasicSqlService  bSqlServ = new BasicSqlService();

			//取得FORM中传入的查询参数
			Object[] fields = new Object[2];
			
			fields[0] = userID;			
			fields[1] = status;			

			/*
			 * 获得查询SQL语句
			 */
			String sql = servSql.getByUserIDSql();
									
			list = bSqlServ.dbRead(cn, sql, fields, new DbLinjuService());
									
		    DbcpPool.returnConnection(cn);
		    
		} catch(Exception ex) 
		{
			/**
			 * 记录相关日志
			 */
			logger.error(ex.getMessage());
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}		
			
		} finally {
			DbcpPool.returnConnection(cn);
		}
		
		return list;
	}
	/**
	 * 
	 * @see net.IUserbasicService.module.other.IUserService
	 * 		#list(net.swift.module.other.ExaQueryBean, net.swift.common.ReturnMessage)
	 */
	public List adlist(LinjuForm theForm,  ReturnMessage msg) 
	{
		List list = new Vector();

		Connection cn = null;
		Statement stmt=null;
		ResultSet rs=null;
		try
		{
			cn = DbcpPool.getConnection();
			
			LinjuServiceSqlMysql servSql = new LinjuServiceSqlMysql();
			
			StringBuffer sb = new StringBuffer(" where 1=1 ");
			
			if(theForm.getQryUserID() > 0){
				
				sb.append(" and UserID = ");
				sb.append(theForm.getQryUserID());
				sb.append(" ");
			}
			
			if(theForm.getQryLinjuID() > 0){
				
				sb.append(" and LinjuID = ");
				sb.append(theForm.getQryLinjuID());
				sb.append(" ");
			}
			
			//查询记录数
			stmt = cn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
			String sql = servSql.getCountSql1();

			logger.debug(sql+sb.toString());
			rs=stmt.executeQuery(sql+sb.toString());
			int nRows = 0;
			if (rs.next())
	           nRows = rs.getInt("COUNT");
			else
			{
	            rs.close();
	            stmt.close();
	            DbcpPool.returnConnection(cn);
			    return list;
			}
			/**
			 * 根据SQL执行结果计算分页相关信息
			 */
			PageCtr page = theForm.getPage();
			page.setTotalNum(nRows);
			page.caculate();
			
			sb.append(" limit ");
			sb.append(page.getPos()-1);
			sb.append(", ");
			sb.append(page.getPageSize());
			
			 //取记录
			 sql = servSql.getRecSql();
			 logger.debug(sql+sb.toString());
			 
			 DbLinjuService dbservice = new DbLinjuService();
			 
			 rs=stmt.executeQuery(sql+sb.toString());
			 while (rs.next())
			 {
				try
				{
					Object obj = dbservice.readSqlResultRecord(rs);
					if (obj != null) list.add(obj);
				}
				catch (Throwable t)
				{
					logger.error(t.getMessage());
				}		
			 }
			 rs.close();
			 stmt.close();
		     DbcpPool.returnConnection(cn);

		} catch(Exception ex) 
		{
			/**
			 * 记录相关日志
			 */
			logger.error(ex.getMessage());
			try {
				if (rs != null)
					rs.close();
				if (stmt != null)
					stmt.close();
				DbcpPool.returnConnection(cn);
			} catch (Exception ex1) {
				ex1.printStackTrace();
			}			
	    }finally {
			try {
				if (rs != null)
					rs.close();
				if (stmt != null)
					stmt.close();
			} catch (Exception ex) {
				ex.printStackTrace();
			}			
			DbcpPool.returnConnection(cn);
		}		
		return list;
	}	
	
	/**
	 * @see net.IUserbasicService.module.other.IUserService
	 * 		#get(net.swift.db.tab_paramnostro, net.swift.common.ReturnMessage)
	 */
	public void get(LinjuForm theForm, ReturnMessage msg) 
	{
		Connection cn = null;
		try
		{
			cn = DbcpPool.getConnection();
			List list = null;

			//取得FORM中传入的查询参数
			Object[] fields = new Object[2];
			
			fields[0] = theForm.getUserID();			
			fields[1] = theForm.getLinjuID();			
			
			LinjuServiceSqlMysql servSql = new LinjuServiceSqlMysql();
			BasicSqlService  bSqlServ = new BasicSqlService();
			
			String sql = servSql.getbykeySql();			
					
			list = bSqlServ.dbRead(cn, sql, fields, new DbLinjuService());
			
			if(list.size() ==0){
				common.setAppFailMsg(msg , " 取记录失败，请检查！");
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return;				
			}
			
			BaseLinju base = (BaseLinju)list.get(0);
				
			BeanUtils.copyProperties(theForm, base);

			DbcpPool.returnConnection(cn);
			return;
			
		} catch(Exception ex) 
		{
			logger.error("System error , param get about invite" + ex);
			common.setAppFailMsg(msg , ex.getMessage());
			try 
			{
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
		} finally {
			DbcpPool.returnConnection(cn);
		}
		
		return ;
	}

	/**
	 * 添加会员好友到表中
	 * @see net.IUserbasicService.module.other.IUserService#add(net.swift.common.ReturnMessage)
	 */
	public void add( LinjuForm theForm, ReturnMessage msg) 
	{
	
		Connection cn = null;
		try
		{
			cn = DbcpPool.getConnection();
			DbcpPool.beginTran(cn);
			
			add(cn, theForm, msg);
			if(msg.getErrCode() != 0){
				return;
			}
			
			DbcpPool.commitTran(cn);
			DbcpPool.closeTran(cn);
			DbcpPool.returnConnection(cn);			

		} catch(Exception ex) 
		{
			common.setAppFailMsg(msg , " 添加好友失败！");
			logger.error("System error , param get about operlog" + ex);
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
		}finally {
			DbcpPool.returnConnection(cn);
		}
		
		return ;
	}
	/**
	 * 添加会员好友到表中
	 * @see net.IUserbasicService.module.other.IUserService#add(net.swift.common.ReturnMessage)
	 */
	public void add(Connection cn, LinjuForm theForm, ReturnMessage msg) 
	{
	
		try
		{
			
			//判断是否在黑名单
			BlacklistServiceImpl blackservice = new BlacklistServiceImpl();
			if(blackservice.isBlack(cn, theForm.getUserID(), theForm.getLinjuID())){
				
				common.setAppFailMsg(msg , " 对方在您的黑名单中，添加关注失败！");
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return;				
			}
			
			LinjuServiceSqlMysql servSql = new LinjuServiceSqlMysql();
			BasicSqlService  bSqlServ = new BasicSqlService();

			Object[] fields2 = new Object[2];
			
			fields2[0] = theForm.getUserID();				
			fields2[1] = theForm.getLinjuID();				
			
			String sql = servSql.getbykeySql();

			//判断是否已经是邻居
			List list = bSqlServ.dbRead(cn, sql, fields2, new DbLinjuService());
			if(list.size() > 0){
				
				BaseLinju base = (BaseLinju)list.get(0);
				if(base.getStatus().equals(GlbFinal.STS_NORMAL)){
					common.setAppFailMsg(msg , " 已经关注！");
					DbcpPool.closeTran(cn);
					DbcpPool.returnConnection(cn);
					return;				
				}
				else{
					
					common.setAppFailMsg(msg , "被拉黑！");
					DbcpPool.closeTran(cn);
					DbcpPool.returnConnection(cn);
					return;				
				}
			}	
			sql = servSql.getInsertSql();
			
			//添加我的邻居
			Object[] fields = new Object[4];
			
			fields[0] = theForm.getUserID();
			fields[1] = theForm.getLinjuID();
			fields[2] = GlbFinal.STS_NORMAL;
			fields[3] = DatetimeUtil.getDatetime();
			
			boolean  res = bSqlServ.dbWrite(cn, sql, fields);
			if(!res){
				common.setAppFailMsg(msg , " 添加邻居失败！");
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return ;
			}
			
			//添加对方的邻居
			
			fields[0] = theForm.getLinjuID();
			fields[1] = theForm.getUserID();
			fields[2] = GlbFinal.STS_NORMAL;
			fields[3] = DatetimeUtil.getDatetime();
			
			res = bSqlServ.dbWrite(cn, sql, fields);
			if(!res){
				common.setAppFailMsg(msg , " 添加邻居失败！");
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return ;
			}
			
			//更新我的邻居数量
			UserSysinfoServiceImpl sysinfoservice = new UserSysinfoServiceImpl();
			UserSysinfoForm sysForm = new UserSysinfoForm();
			
			sysForm.setUserID(theForm.getUserID());
			sysForm.setLinjuNum(1);
			sysinfoservice.update(cn, sysForm, msg);
			if(msg.getErrCode() != 0){
				return;
			}
			//更新对方邻居数量
			sysForm.setUserID(theForm.getLinjuID());
			sysForm.setLinjuNum(1);
			sysinfoservice.update(cn, sysForm, msg);
			if(msg.getErrCode() != 0){
				return;
			}
			
//			//发送私信通知被关注
//			MessageServiceImpl msgservice = new MessageServiceImpl();
//			MessageForm msgForm = new MessageForm();
//			MsgcontForm msgcontForm = new MsgcontForm();
//			
//			msgForm.setReceiver(theForm.getLinjuID());
//			msgForm.setSender(theForm.getUserID());
//			msgForm.setMtype(GlbFinal.MTYPE_GUANGZHU);
//			msgForm.setSendertype("1");
//			msgForm.setTitle("你好，" + JstlFun.GetUserNick(theForm.getUserID()) + "关注了你");
//			msgcontForm.setMsg("你好，" + JstlFun.GetUserNick(theForm.getUserID()) + "关注了你");
//			
//			msgservice.add(cn, msgForm, msgcontForm, msg);
//			if(msg.getErrCode() != 0){
//				return;
//			}
			
			//添加用户动态表
			OperLogServiceImpl logservice = new OperLogServiceImpl();
			OperLogForm logForm = new OperLogForm();
			
			logForm.setUserID(theForm.getUserID());
			logForm.setType(GlbFinal.OPERTYPE_JIAHAOYOU);				//加好友
			
			String[] arr = new String[7];
			arr[0] = JstlFun.GetUserNick(theForm.getUserID());			//主操作者		
			arr[1] = "关注了";											//主动者与被动者的关系副词
			arr[2] = String.valueOf(theForm.getLinjuID());				//被动接受者ID
			arr[3] =  JstlFun.GetUserNick(theForm.getLinjuID());		//被动接受者姓名
			arr[4] = "";												//操作
			arr[5] = "";												//操作对象名称
			arr[6] = "";												//操作对象KEY，多个字段以'|'分隔

			logForm.setLogarr(arr);
			
			logservice.add(cn, logForm, msg);
			if(msg.getErrCode() != 0){
				return;
			}	
			
		} catch(Exception ex) 
		{
			common.setAppFailMsg(msg , " 添加好友失败！");
			logger.error("System error , param get about operlog" + ex);
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
		}finally {
		}
		
		return ;
	}
	/**
	 * 拉黑
	 * @see net.IUserbasicService.module.other.IUserService#update(net.swift.common.ReturnMessage)
	 */
	public void addblack(LinjuForm theForm, ReturnMessage msg) 
	{
		
		Connection cn = null;
		try
		{
			cn = DbcpPool.getConnection();
			
			DbcpPool.beginTran(cn);

			delete(cn, theForm, msg);	
			if(msg.getErrCode() != 0){
				return;
			}
			//计算积分
			JifenServiceImpl jifenservice = new JifenServiceImpl();
			
			jifenservice.compjf(cn, 21, theForm.getLinjuID(), msg);
			if(msg.getErrCode() != 0){
				return;
			}				
			
//			//添加到黑名单
//			BlacklistServiceImpl blackservice = new BlacklistServiceImpl();
//			BlacklistForm blackform = new BlacklistForm();
//			
//			blackform.setUserID(theForm.getUserID());
//			blackform.setBlackID(theForm.getLinjuID());
//			
//			blackservice.add(cn, blackform, msg);
//			if(msg.getErrCode() != 0){
//				return;
//			}
			
			DbcpPool.commitTran(cn);
			DbcpPool.closeTran(cn);
			DbcpPool.returnConnection(cn);
			return;
			
		} catch(Exception ex) 
		{
			logger.error("System error , param get about invite" + ex);
			common.setAppFailMsg(msg , ex.getMessage());
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
		} finally {
			DbcpPool.returnConnection(cn);
		}
		
		return ;
	}
	/**
	 * 删除好友记录
	 * @see net.IUserbasicService.module.other.IUserService#update(net.swift.common.ReturnMessage)
	 */
	public void delete(LinjuForm theForm, ReturnMessage msg) 
	{
		
		Connection cn = null;
		try
		{
			cn = DbcpPool.getConnection();
			
			DbcpPool.beginTran(cn);

			delete(cn, theForm, msg);	
			if(msg.getErrCode() != 0){
				return;
			}
			
			DbcpPool.commitTran(cn);
			DbcpPool.closeTran(cn);
			DbcpPool.returnConnection(cn);
			return;
			
		} catch(Exception ex) 
		{
			logger.error("System error , param get about invite" + ex);
			common.setAppFailMsg(msg , ex.getMessage());
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
		} finally {
			DbcpPool.returnConnection(cn);
		}
		
		return ;
	}
	/**
	 * 删除好友记录
	 * @see net.IUserbasicService.module.other.IUserService#update(net.swift.common.ReturnMessage)
	 */
	public void delete(Connection cn, LinjuForm theForm, ReturnMessage msg) 
	{
		
		try
		{

			LinjuServiceSqlMysql servSql = new LinjuServiceSqlMysql();
			BasicSqlService  bSqlServ = new BasicSqlService();

			//取得FORM中传入的查询参数
			Object[] fields = new Object[2];
			
			fields[0] = theForm.getUserID();
			fields[1] = theForm.getLinjuID();
			
			String sql = servSql.getDeleteSql();
								
			boolean  res = bSqlServ.dbWrite(cn, sql, fields);
			if(!res){
				common.setAppFailMsg(msg , " 更新记录失败，请检查！");
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return;
			}
			
			//我的 邻居数量
			UserSysinfoServiceImpl syservice  = new UserSysinfoServiceImpl();
			
			UserSysinfoForm sysForm = new UserSysinfoForm();
			sysForm.setUserID(theForm.getUserID());

			sysForm.setFirendNum(-1);
			syservice.update(cn, sysForm, msg);
			if(msg.getErrCode() != 0){
				return ;
			}			
			
			//
			fields[0] = theForm.getLinjuID();
			fields[1] = theForm.getUserID();
			
			sql = servSql.getDeleteSql();
								
			res = bSqlServ.dbWrite(cn, sql, fields);
			if(!res){
				common.setAppFailMsg(msg , " 更新记录失败，请检查！");
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return;
			}
			//更新 对方邻居数量
			sysForm.setUserID(theForm.getLinjuID());

			sysForm.setFirendNum(-1);
			syservice.update(cn, sysForm, msg);
			if(msg.getErrCode() != 0){
				return ;
			}			
			
			
			return;
			
		} catch(Exception ex) 
		{
			logger.error("System error , param get about invite" + ex);
			common.setAppFailMsg(msg , ex.getMessage());
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
		} finally {
		}
		
		return ;
	}	
	/**
	 * 更新一条指定记录
	 * @see net.IUserbasicService.module.other.IUserService#update(net.swift.common.ReturnMessage)
	 */
	public void update(LinjuForm theForm, ReturnMessage msg) 
	{
		
		Connection cn = null;
		try
		{
			cn = DbcpPool.getConnection();
			
			DbcpPool.beginTran(cn);
			List list = null;

			//取得FORM中传入的查询参数
			Object[] fields = new Object[2];
			
			fields[0] = theForm.getUserID();			
			fields[1] = theForm.getLinjuID();			
			
			LinjuServiceSqlMysql servSql = new LinjuServiceSqlMysql();
			BasicSqlService  bSqlServ = new BasicSqlService();
			
			String sql = servSql.getbykeySql();			
					
			list = bSqlServ.dbRead(cn, sql, fields, new DbLinjuService());
			
			if(list.size() ==0){
				common.setAppFailMsg(msg , " 取记录失败，请检查！");
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return;				
			}
			
			BaseLinju base = (BaseLinju)list.get(0);
				
			Object[] fields2 = new Object[4];
			
			fields2[0] = theForm.getStatus();			
			fields2[1] = DatetimeUtil.getDatetime();			
			fields2[2] = theForm.getUserID();			
			fields2[3] = theForm.getLinjuID();			
			
			
			sql = servSql.getUpdateSql();			
			
			boolean  res = bSqlServ.dbWrite(cn, sql, fields2);
			if(!res){
				common.setAppFailMsg(msg , " 更新记录失败，请检查！");
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
				return;
			}
			if(theForm.getStatus().equals(GlbFinal.FRSTS_SHENDU)){
				//添加用户动态表
				OperLogServiceImpl logservice = new OperLogServiceImpl();
				OperLogForm logForm = new OperLogForm();
				
				logForm.setUserID(theForm.getUserID());
				logForm.setType(GlbFinal.OPERTYPE_LINJU);						//操作板块：添加关注
				
				String[] arr = new String[7];
				arr[0] = JstlFun.GetUserNick(theForm.getUserID());				//主操作者		
				arr[1] = "和";													//主动者与被动者的关系副词
				arr[2] = String.valueOf(theForm.getLinjuID());					//被动接受者ID
				arr[3] = JstlFun.GetUserNick(theForm.getLinjuID());				//被动接受者姓名
				arr[4] = " 成为了深度交往邻居";									//操作
				arr[5] = " ";													//操作对象名称
				arr[6] = " ";													//
				
				logForm.setLogarr(arr);
				
				logservice.add(cn, logForm, msg);
				if(msg.getErrCode() != 0){
					return;
				}	
				//计算积分
				JifenServiceImpl jifenservice = new JifenServiceImpl();
				
				jifenservice.compjf(cn, 20, theForm.getLinjuID(), msg);
				if(msg.getErrCode() != 0){
					return;
				}	
				
			}
			
			
			
			DbcpPool.commitTran(cn);
			DbcpPool.closeTran(cn);
			DbcpPool.returnConnection(cn);
			return;
			
		} catch(Exception ex) 
		{
			logger.error("System error , param get about invite" + ex);
			common.setAppFailMsg(msg , ex.getMessage());
			try 
			{
				DbcpPool.rollBackTran(cn);
				DbcpPool.closeTran(cn);
				DbcpPool.returnConnection(cn);
			} catch(Exception ex1) 
			{
				ex1.printStackTrace();
				logger.error("事务回滚操作失败!ExaServiceImpl->add(01)" , ex1);
			}			
		} finally {
			DbcpPool.returnConnection(cn);
		}
				
		return ;
	}

}
